//
// Created by zerax on 2020/10/23.
//

#pragma once

#include <SDL.h>
#include <functional>

class Game {
public:
    using OnMouseClickCallback = std::function<void(int)>;

    virtual bool init();
    void run();

protected:
    virtual void update() = 0;

    void setOnMouseClick(OnMouseClickCallback&& onMouseClick);
    void wrapMouseInWindow(int x, int y);
    float getDeltaTime();
    int getScreenWidth() const;
    int getScreenHeight() const;
private:
    bool m_running = false;
    OnMouseClickCallback m_onMouseClick;

    unsigned int m_lastTime = 0;
    float m_deltaTime = 0;

    SDL_Window* m_window = nullptr;
    SDL_GLContext m_glContext = nullptr;
};


